<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core">
<head>
<ui:insert name="header">
	<ui:include src="template/header.xhtml" />
</ui:insert>
</head>
<body>
	<f:view>
		<ui:include src="template/banner.xhtml" />

		<h:form id="form">

			<h:commandLink id="check" action="cart" immediate="true"
				rendered="#{cart.numberOfItems > 0}">
				<h:outputText value="#{bundle.CartCheck}" />
			</h:commandLink>

			<h:outputText escape="false" value="&nbsp;"
				rendered="#{cart.numberOfItems > 0}" />

			<h:commandLink id="clear" action="#{catalog.clear}" immediate="true"
				rendered="#{cart.numberOfItems > 0}">
				<h:outputText value="#{bundle.ClearCart}" />
			</h:commandLink>

			<h:outputText escape="false" value="&nbsp;"
				rendered="#{cart.numberOfItems > 0}" />

			<h:commandLink id="buy" action="#{catalog.checkout}" immediate="true"
				rendered="#{cart.numberOfItems > 0}">
				<h:outputText value="#{bundle.Buy}" />
			</h:commandLink>

			<table border="0" class="list-background"
				summary="Add books from the catalog to your shopping cart.">
				<thead>
					<tr>
						<th colspan="4" class="list-header"><h:outputText
								value="#{bundle.Choose}" /></th>
					</tr>
					<tr>
						<th class="list-header"><h:outputText
								value="#{bundle.ItemTitle}" /></th>
						<th class="list-header"><h:outputText value="#{bundle.By}" /></th>
						<th class="list-header"><h:outputText
								value="#{bundle.ItemPrice}" /></th>
						<th class="list-header"><h:outputText
								value="#{bundle.CartAdd}" /></th>
					</tr>
				</thead>
				<tfoot>
					<tr>
						<td colspan="4" class="list-header-left"><h:outputText
								value="#{bundle.Total} #{cart.numberOfItems}" /></td>
					</tr>
				</tfoot>


				<c:forEach items="#{bookCtrl.books}" var="book" varStatus="stat">
					<c:set var="book" scope="request" value="${book}" />
					<tr
						class="${(stat.index % 2) == 0 ? 'list-row-even' : 'list-row-odd'}">
						<td class="list-column-left"><h:commandLink
								action="#{catalog.details}" value="#{book.title}">
								<f:setPropertyActionListener target="#{sessionScope.selected}"
									value="#{book}" />
							</h:commandLink></td>
						<td class="list-column-left"><h:outputText id="firstName"
								value="#{book.firstName} #{book.lastName}" /></td>
						<td class="list-column-right"><h:outputText id="price"
								value="#{book.price}">
								<f:convertNumber type="currency" />
							</h:outputText></td>

						<td class="list-column-center"><h:commandButton id="add"
								action="#{catalog.add}" value="#{bundle.CartAdd}">
								<f:setPropertyActionListener target="#{sessionScope.selected}"
									value="#{book}" />
							</h:commandButton></td>
					</tr>
				</c:forEach>
			</table>
		</h:form>
	</f:view>
</body>
</html>